package top.zk123.chain.mapper;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import top.zk123.chain.bean.Message;

import java.util.List;

public interface MessageMapper extends JpaRepository<Message, String> {

    @Query(value = "select * from message where receiver = :userId", nativeQuery = true)
    List<Message> findByReceiver(String userId);

    @Query(value = "select * from message where cert_uid = :certUID", nativeQuery = true)
    Message findByCertUID(String certUID);

    @Query(value = "select * from message where receiver = :userId and state ='已授权' ", nativeQuery = true)
    List<Message> findByReceiverAndState(String userId);
}
